<?php
/**
 * Created by PhpStorm.
 * User: ming
 * Date: 17-8-16
 * Time: 下午5:12
 */

$serv=new swoole_server("0.0.0.0",9501);

$serv->set(array('task_worker_num'=>4));

$serv->on("receive",function ($serv,$fd,$from_id,$data){
   $task_id=$serv->task($data);
   echo "异步 ID: $task_id \n";

});

$serv->on('task',function ($serv,$task_id,$from_id,$data){
    echo "执行 异步ID: $task_id";
    $serv->finish("$data-> OK");
});


$serv->on('finish',function ($serv,$task_id,$data){
   echo  "执行完成";
});

$serv->start();